


//
//  ZBookMsgDetailVC.m
//  ZQLearn
//
//  Created by macfeel on 2019/4/25.
//  Copyright © 2019 macfeel. All rights reserved.
#import "ShareView.h"
#import "BookDetailBottomView.h"
#import "myBookModel.h"
//#import "BookChapterModel.h"
//#import "PaintReaderViewController.h"
#import "ReadFeelingsViewController.h"
#import "MemberViewController.h"
#import "ZBookMsgDetailVC.h"
#import "BookDetialTableViewCell.h"
#import "BookDetailHeadView.h"
#import "ReadModel.h"
#import "PayModel.h"


@interface ZBookMsgDetailVC ()<UITableViewDelegate,UITableViewDataSource,ZFActionSheetDelegate>

@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *dataArray;
@property (nonatomic,strong)BookDetailHeadView *headView;
@property (nonatomic,strong)NSArray *names;
@property (nonatomic,strong)NSArray *contents;
@property (nonatomic,strong)NSArray *dates;
@property (nonatomic,strong)NSMutableArray *photoArray;

@property (nonatomic,copy)NSString *pathString;

@property (nonatomic,copy)NSString *txtContent;

///书籍或视频的名字
@property (nonatomic,copy)NSString *name;
///作者
@property (nonatomic,copy)NSString *auther;

///版权页面
@property (nonatomic,copy)NSString *banquanPhoto;

///
@property (nonatomic,assign)BOOL isVip;

///支付状态
@property (nonatomic,copy)NSString *payStatus;

@property (nonatomic,copy)NSString *orderId;

///封面  版权  首章id
@property (nonatomic,copy)NSString *coverId;

@property (nonatomic,copy)NSString *banquanId;

@property (nonatomic,copy)NSString *firstChapterId;
@property (nonatomic,strong)myBookModel *bookModel;
@property (nonatomic,strong)NSMutableArray *chapterArr;


///底部视图
@property(nonatomic,strong)BookDetailBottomView *bottomView;


@end



@implementation ZBookMsgDetailVC
#define cellIdentifier @"bookdetail"
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0 , 1.5, ScreenWidth , ScreenHeight-NavBarHeight-53) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 70;
        _tableView.backgroundColor = kBackgroundColor;
        [_tableView registerNib:[UINib nibWithNibName:@"BookDetialTableViewCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
//        WeakStament(ws);
//        _tableView.mj_header = [CustomRefreshHeader headerWithRefreshingBlock:^{
//            [ws refreshData];
//        }];
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.tableFooterView = [UIView new];
        
    }
    return _tableView;
}

////***************************************************************
#pragma mark - 绘本 封面版权章节内容同时获取
//获取封面ID 也就是绘本首章的id
-(void)startLoadBookMsg{
    /////对于绘本来说  kBookDocumentAndContentUrl  这个接口可以拿到 封面id 版权页id 还有正文首页id
    ////对于文字电子书来说 kBookDocumentAndContentUrl  这个接口拿到所有的章节和内容
    NSDictionary *dic = @{@"bookInfo.id":self.MModel.ID?:@"",@"pageSize":@"200",@"pageIndex":@"1"};
    //kPaintPagesUrl @"/app/readClass/listBookImageInfo"
    [ZNetworkService postRequestWithBaseUrl:kBookDocumentAndContentUrl setParameters:dic success:^(id result) {
        //获取封面ID
        if (([self.MModel.isPaint integerValue]==1)) {
            //绘本需要存储 封面id 版权id  正文首章id
            NSArray *arr = result[@"result"];
            ////绘本这块  返回的数据 因为历史原因
            if (arr.count==3) {
                
                ///这个逻辑的存在是历史遗留问题，一下返回了三个id 就直接用了 ，这个是最初的最方便的处理方式
                
                self.coverId = [[arr firstObject]objectForKey:@"id"];
                self.banquanId = [[arr objectAtIndex:1]objectForKey:@"id"];
                self.firstChapterId = [[arr lastObject]objectForKey:@"id"];
        YYLog(@"**1:%@2:%@3:%@",self.coverId,self.banquanId,self.firstChapterId);
                ////这个就是为了拿到版权页面
                [self getRightWithId:self.banquanId];
                
                ///这个是拿到所有的章节内容
                [self getChapter];
                
            }else{
                ///从这里拿到封面id 然后调用next接口拿到版权id
                ////后来的大多数的绘本走的都是这里的逻辑
                ////后来的大多数的绘本走的都是这里的逻辑
                ////后来的大多数的绘本走的都是这里的逻辑
                NSArray *arr = result[@"result"];
                NSDictionary *dict = [arr firstObject];
                NSString *coverId = dict[@"id"];
                [self getRightWithId:coverId];
            }
        }else if ([self.MModel.catelogType integerValue]) {
            /// 2 走的也是绘本阅读只不过是两种不同的逻辑
            /// 这个 是教材馆  教辅馆  进来的逻辑，因为这个字段时候来加进来的
            NSArray *arr = result[@"result"];
            NSDictionary *dict = [arr firstObject];
            NSString *coverId = dict[@"id"];
            YYLog(@"%@",coverId);
            
            
            if ([self.MModel.gradeName isEqualToString:@"小学阅读"]) {
                ///小学阅读走的和上面120行代码大多数绘本走的分之一样
                [self getRightWithId:coverId];
            }else{
                ///教材馆教辅馆专用分之
                [self jiaocaiAndJiaofuZhuanYongNextChapterWithID:coverId];
            }
            
            
            
            
        }
    } fail:^(NSError *error) {
    } delegater:nil];
}


///获取章内容 这个是一下子拿到全部章节内容
-(void)getChapter{
    
    NSDictionary *dic = @{@"bookCatalogInfo.id":self.firstChapterId?:@"",@"pageSize":@"99",@"pageIndex":@"1"};
    [self.photoArray removeAllObjects];
    [ZNetworkService postRequestWithBaseUrl:kPaintPagesUrl setParameters:dic success:^(id result) {
        YYLog(@"%@",result);
        if ([result[@"errorCode"]integerValue]==0) {
            NSArray *arr = result[@"result"];
            for (NSDictionary *dic in arr) {
                ReadModel *model = [ReadModel mj_objectWithKeyValues:dic];
                model.photo = [NSString stringWithFormat:@"%@%@",kPicServerUrl,model.photo];
                NSString *url = model.photo;
                ///因为我们这图片链接中有中文或者特殊字符的话，需要进行utf8转码处理
                url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                [self.photoArray addObject:url];
            }
            ///插入封面
            [self.photoArray insertObject:self.MModel.picUrl atIndex:0];
            [self.photoArray insertObject:self.banquanPhoto?:@"" atIndex:1];
            YYLog(@"当前版权:%@",self.banquanPhoto);
            YYLog(@"当前封面:%@",self.MModel.picUrl);
            YYLog(@"%@",self.photoArray);
        }
    } fail:^(NSError *error) {
        
    } delegater:nil];
    
    
}
////***************************************************************

////***************************************************************
#pragma mark - 封面版权章节分开获取，就是后来和玉龙一直讨论的方式，这是后加的那种方式，这里面展示时候封面和版权有了，不用在单独往数组里面加了

///请求封面
-(void)getCover{
    
    ///bookCatalogInfo.id=2c913a79689845390168a2834cfd2be4&pageSize=99&pageIndex=1
    
    NSDictionary *dic = @{@"bookInfo.id":self.MModel.ID,@"pageSize":@"5",@"pageIndex":@"1",};
   
    [ZNetworkService postRequestWithBaseUrl:kBookDocumentAndContentUrl setParameters:dic success:^(id result) {
        
        if ([result[@"errorCode"]integerValue]==0) {
            
            NSArray *arr = result[@"result"];
            NSString *coverId = [[arr firstObject]objectForKey:@"id"];
            [self getRightWithId:coverId];
        }
        
        YYLog(@"%@",result);
        
    } fail:^(NSError *error) {
        
    } delegater:nil];
}

///版权或者章节
-(void)getRightWithId:(NSString *)rightId{
    ///bookCatalogInfo.id=2c913a796a1f9d65016a29239816444b&pageSize=99&pageIndex=1
    NSDictionary *dic = @{@"bookCatalogInfo.id":rightId,@"pageSize":@"99",@"pageIndex":@"1",};
    [ZNetworkService postRequestWithBaseUrl:kPaintPagesUrl setParameters:dic success:^(id result) {
        if ([result[@"errorCode"]integerValue]==0) {
            
            NSArray *arr = result[@"result"];
        
            if (arr.count==1) {
                
                ////这里只是为了拿到版权 那个页面
                NSString *banquanPhoto = [[arr firstObject]objectForKey:@"photo"];
                NSString *url = [banquanPhoto stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                self.banquanPhoto = [NSString stringWithFormat:@"%@%@",kPicServerUrl,url];
                YYLog(@"%@",self.banquanPhoto);
                
            }else{
                
                ///这里拿到的是所有的内容的图片
                [self.photoArray removeAllObjects];
                for (NSDictionary *dic in arr) {
                    ReadModel *model = [ReadModel mj_objectWithKeyValues:dic];
                    model.photo = [NSString stringWithFormat:@"%@%@",kPicServerUrl,model.photo];
                    NSString *url = model.photo;
                    ///因为我们这图片链接中有中文或者特殊字符的话，需要进行utf8转码处
                    url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                    
                    [self.photoArray addObject:url];
                    YYLog(@"未删减数量：%lu",(unsigned long)self.photoArray.count);
                }
            }
        
            
            ///将版权先去掉
//            [self.photoArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//                if (idx==1) {
//                    [self.photoArray removeObject:obj];
//                }
//            }];

//            YYLog(@"当前绘本图片组:%@",self.photoArray);
//            YYLog(@"%@",self.photoArray);
        }
        YYLog(@"%@",result);
    } fail:^(NSError *error) {
    } delegater:nil];
}

////***************************************************************
///底部条添加
-(void)addBottomView{
    
    self.bottomView = [[[NSBundle mainBundle]loadNibNamed:@"BookDetailBottomView" owner:self options:nil]lastObject];
    
    self.bottomView.frame = CGRectMake(0, ScreenHeight-NavBarHeight-50, ScreenWidth, 50);
    [self.view addSubview:self.bottomView];
    [self.view bringSubviewToFront:self.bottomView];
    
    [self.bottomView.leftBtn addTarget:self action:@selector(leftBtnAction) forControlEvents:UIControlEventTouchUpInside];
    
    [self.bottomView.rightBtn addTarget:self action:@selector(rightBtnAction) forControlEvents:UIControlEventTouchUpInside];
    
    [self.bottomView.midBtn addTarget:self action:@selector(midBtnAction) forControlEvents:UIControlEventTouchUpInside];
    
}
///加入书架
-(void)leftBtnAction{
    [self addToShelf];
}
///收藏
-(void)rightBtnAction{
    [self collect];
}

#pragma mark - 开始阅读
///开始阅读
-(void)midBtnAction{
    [self readAction:nil];
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self.navigationItem setItemWithTitle:@"书籍详情" textColor:kNavigationTitleColor fontSize:18 itemType:center];
//    [self addNavgationRightButtonWithFrame:CGRectMake(0, 0, 35, 35) title:@"加入书架" Image:@"" selectedIMG:@"" tartget:self action:@selector(addToShelf)];
    [self addNavgationRightButtonWithFrame:CGRectMake(0, 0, 35, 35) title:@"" Image:@"share" selectedIMG:@"" tartget:self action:@selector(shareAction)];
    self.photoArray = [NSMutableArray array];
    self.chapterArr = [NSMutableArray array];
    [self.view addSubview:self.tableView];
    BookDetailHeadView *head = [[[NSBundle mainBundle]loadNibNamed:@"BookDetailHeadView" owner:self options:nil]lastObject];
    self.tableView.tableHeaderView = head;
    self.headView = head;
    
    self.names = @[@"ZQ18788890765",@"ZQ18619082351",@"ZQ1870065765",];
    self.contents = @[@"还不错",@"给点个赞",@"nice,I like",];
    self.dates = @[@"2019-03-01",@"2019-04-21",@"2019-05-15",];
    [self.headView.readBtn addTarget:self action:@selector(readAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.headView.moreBtn addTarget:self action:@selector(moreAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.headView.openHuiyuan addTarget:self action:@selector(openAction:) forControlEvents:UIControlEventTouchUpInside];
    
    ///这个购买按钮是否显示 判断3个条件 paymentStatus  支付状态 0未支付  1已支付
    [self CheckpayStatus];
   
    [self.headView.twoyuanGouBtn addTarget:self action:@selector(gouAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [self loadData];
    // Do any additional setup after loading the view from its nib.
    [self addBottomView];
}
#pragma mark - 加入书架
///将当前书籍添加到书架
-(void)addToShelf{
///userInfo.id=2c913a796ac01ec2016ac3be98fd0071&collectionId=2c913a79689845390168a2834cfa2be3&classType=1&ids=2c913a79689845390168a2834cfa2be3&addType=1
    NSDictionary *dict = @{@"classType":@"2",@"userInfo.id":[UserInfoSave shareInstance].uid?:@"",@"collectionId":self.MModel.ID?:@"",@"addType":@"1"};
    [ZNetworkService postRequestWithBaseUrl:kBookshelfupdateBookUrl setParameters:dict success:^(id result) {
        
        YYLog(@"%@",result);
        if ([result[@"errorCode"]integerValue]==0) {
            [AFToast showText:@"添加成功"];
        }else{
            [AFToast showText:@"已经添加过"];
        }
        
    } fail:^(NSError *error) {
        
    } delegater:nil];
}
#pragma mark - 收藏
///收藏
-(void)collect{
    
    ///type 1资讯  2视频  3图书    classType 1资讯  2课内  3课外
    //addType   1添加  2删除
    NSDictionary *dict = @{@"type":@"3",@"classType":@"3",@"userInfo.id":[UserInfoSave shareInstance].uid?:@"",@"collectionId":self.MModel.ID?:@"",@"addType":@"1"};
    [ZNetworkService postRequestWithBaseUrl:kCollectUrl setParameters:dict success:^(id result) {
        
        YYLog(@"%@",result);
        if ([result[@"errorCode"]integerValue]==0) {
            [AFToast showText:@"收藏成功"];
        }else{
            [AFToast showText:@"已收藏过"];
        }
        
    } fail:^(NSError *error) {
        
    } delegater:nil];
    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setHidden:NO];
    if (self.MModel.name) {
        self.headView.titleLab.text = self.MModel.name;
        self.name = self.MModel.name;
        self.headView.autherLab.text = [NSString stringWithFormat:@"作者:%@",self.MModel.author?:@"智秦"];
        self.headView.jianjieLab.text = [NSString stringWithFormat:@"简介:%@",self.MModel.content?:@""];
        [self.headView.headImg sd_setImageWithURL:[NSURL URLWithString:self.MModel.picUrl] placeholderImage:nil];
    }
    
    ///请求绘本相关内容
    [self startLoadBookMsg];
    
//    [self getCover];
}
///判断支付按钮是否出现
-(void)viewDidAppear:(BOOL)animated{
    
    [super viewDidAppear:animated];
    
    NSString *price = self.MModel.price;

    if ([[UserModel shareInstance].isVip integerValue]==1) {
        
        self.headView.twoyuanGouBtn.hidden = YES;
        
    }else{
        
        if ([price integerValue]==0) {
            //价钱为空
            self.headView.twoyuanGouBtn.hidden = YES;
            
        }else{
            //价钱不为空再看是否购买了
//            self.headView.twoyuanGouBtn.hidden = false;
            if ([self.payStatus isEqualToString:@"1"]) {
                
                self.headView.twoyuanGouBtn.hidden = YES;
                
            }else{
                
                self.headView.twoyuanGouBtn.hidden = NO;
                
            }
        }
    }
}

///为了防止重复请求
-(void)backItemClick{
    [super backItemClick];
    [UserModel shareInstance].isFromReader=false;
}

///判断购买状态
-(void)CheckpayStatus{
    
    if ([self.MModel.price integerValue]==0) {
        
        ///0表示免费 就不用判断购买状态了
        return;
        
    }
    NSDictionary *dic = @{@"buyRecordsId":self.MModel.ID?:@"",@"userInfo.id":[UserInfoSave shareInstance].uid?:@""};
    [ZNetworkService postRequestWithBaseUrl:kPayStatusUrl setParameters:dic success:^(id result) {
//        YYLog(@"%@",result);
        if ([result[@"errorCode"]integerValue]==0) {
            NSString *paymentStatus = result[@"paymentStatus"];
            self.payStatus = paymentStatus;
            YYLog(@"%@",self.payStatus);
        }
        
    } fail:^(NSError *error) {
        
    } delegater:nil];
}

////
- (void)loadData{
    
    if ([UserModel shareInstance].isFromReader==YES) {
        ///如果是退出阅读器后状态就不再请求数据
        return;
    }

    NSDictionary *dic = @{@"bookInfo.id":self.MModel.ID?:@"",@"pageSize":@"99",@"pageIndex":@"1"};
    WeakStament(weakself);
    
//    [SVProgressHUD show];

    [ZNetworkService postRequestWithBaseUrl:kBookDocumentAndContentUrl setParameters:dic success:^(id result) {
        
    } fail:^(NSError *error) {
//        [SVProgressHUD dismiss];
    } delegater:nil];
    
}
#pragma mark - 点击阅读
///开始阅读  能否阅读的逻辑和购买按钮的隐藏逻辑是一样的
- (void)readAction:(UIButton *)btn
{
}

#pragma mark - 开始读书
///开始读书  这是纸质版电子书
-(void)readBook{
}

///开始读书 绘本
-(void)readPaintBook{
}


#pragma mark - 电子书测试
///开始阅读 这个目前是个测试 测试写入电子书后，通过什么方式来获取
- (void)gouAction:(UIButton *)btn
{
    [self addOrderOfSource];
}

///添加资源订单
-(void)addOrderOfSource{
    ///buyRecordsType   1电子书  2视频
    //buyRecordsName  购买的名称
    NSDictionary *dict = @{@"bookInfo.discount":@"1",@"bookInfo.price":@"2",@"userInfo.id":[UserInfoSave shareInstance].uid?:@"",@"bookInfo.id": self.MModel.ID?:@"",@"buyRecordsType":@"1",@"buyRecordsName":self.name?:@"",};
    [ZNetworkService postRequestWithBaseUrl:kAddSourceOrderUrl setParameters:dict success:^(id result) {
        YYLog(@"%@",result);
        if ([result[@"errorCode"]integerValue]==0) {
            NSString *orderId = result[@"result"][@"id"];
            self.orderId = orderId;
            ZFActionSheet *sheet = [ZFActionSheet actionSheetWithTitle:nil confirms:@[@"微信支付",] cancel:@"取消" style:ZFActionSheetStyleDefault];
            sheet.delegate = self;
            [sheet show];
        }
    } fail:^(NSError *error) {
        
    } delegater:nil];
}

#pragma mark - zfdelegate
-(void)clickAction:(ZFActionSheet *)actionSheet atIndex:(NSUInteger)index{
    if (index==0) {
        //微信支付
        //type  1 商城里的商品  2 vip   3 图书视频等资源
        //paytype 1支付宝  2微信
        ///type 1商城商品  2vip  3电子书资源   注意修改type
        NSDictionary *dict = @{@"id":self.orderId?:@"",@"type":@"3",@"paytype":@"2",};
        [ZNetworkService postRequestWithBaseUrl:kCallPayUrl setParameters:dict success:^(id result) {
            YYLog(@"%@",result);
            if ([result[@"errorCode"]integerValue]==0) {
                NSDictionary *ddic = result[@"result"];
                PayModel *model = [PayModel mj_objectWithKeyValues:ddic];
                [PayModel  wxPay:model];
            }else{
                [AFToast showText:@"接口返回错误"];
            }
        } fail:^(NSError *error) {
            
        } delegater:nil];
        
    }else{
        
        //支付宝
    }
}
//更多
- (void)moreAction:(UIButton *)btn
{
    //读后感页面
    ReadFeelingsViewController *member = [ReadFeelingsViewController new];
    [self.navigationController pushViewController:member animated:YES];
    
}
//开通会员
- (void)openAction:(UIButton *)btn
{
    MemberViewController *member = [MemberViewController new];
    [self.navigationController pushViewController:member animated:YES];
    
}


#pragma mark - datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   
        //视频
        BookDetialTableViewCell *cell  = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
//        NewsModel *model = self.dataArray[indexPath.row];
//        [videoCell.headImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kPicServerUrl,model.photo]] placeholderImage:nil];
//        videoCell.titleLab.text = model.title;
    cell.nameLab.text = self.names[indexPath.row];
    cell.contentLab.text = self.contents[indexPath.row];
    cell.timeLab.text = self.dates[indexPath.row];
    return cell;
   
    
}

#pragma delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
}








#pragma mark - JJJJ星号里面 是仅仅教材馆和教辅馆用的 其他逻辑不用
///JJJJJJJJJJJJJ****************************JJJJJJJJJJJJJJJJJJJJJJJJJJJJ
-(void)jiaocaiAndJiaofuZhuanYongNextChapterWithID:(NSString *)ss{
    
    NSDictionary *dic = @{@"id":ss,};
    
    [self.photoArray removeAllObjects];
    
    [ZNetworkService postRequestWithBaseUrl:kPaintBookNextUrl setParameters:dic success:^(id result) {
        YYLog(@"%@",result);
        if ([result[@"errorCode"]integerValue]==0) {
            
            NSDictionary *dict = result[@"result"];
            
            NSString *Id = dict[@"id"];
            
            [self getChapterWithID:Id];
            //            for (NSDictionary *dic in arr) {
            //                ReadModel *model = [ReadModel mj_objectWithKeyValues:dic];
            //                model.photo = [NSString stringWithFormat:@"%@%@",kPicServerUrl,model.photo];
            //                NSString *url = model.photo;
            //                ///因为我们这图片链接中有中文或者特殊字符的话，需要进行utf8转码处理
            //                url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            //                [self.photoArray addObject:url];
            //            }
            //            ///插入封面
            //            [self.photoArray insertObject:self.MModel.picUrl atIndex:0];
            //
            //            YYLog(@"当前绘本图片组:%@",self.photoArray);
            //            YYLog(@"%@",self.photoArray);
            
        }
        
    } fail:^(NSError *error) {
        
    } delegater:nil];
    
}
////和上个方法紧紧相连，仅仅是服务于教材馆 和 教辅馆
-(void)getChapterWithID:(NSString *)string{
    
    NSDictionary *dic = @{@"bookCatalogInfo.id":string?:@"",@"pageSize":@"99",@"pageIndex":@"1"};
    [self.photoArray removeAllObjects];
    [ZNetworkService postRequestWithBaseUrl:kPaintPagesUrl setParameters:dic success:^(id result) {
        YYLog(@"%@",result);
        if ([result[@"errorCode"]integerValue]==0) {
            NSArray *arr = result[@"result"];
            for (NSDictionary *dic in arr) {
                ReadModel *model = [ReadModel mj_objectWithKeyValues:dic];
                model.photo = [NSString stringWithFormat:@"%@%@",kPicServerUrl,model.photo];
                NSString *url = model.photo;
                ///因为我们这图片链接中有中文或者特殊字符的话，需要进行utf8转码处理
                url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                [self.photoArray addObject:url];
            }
            ///插入封面
            //            [self.photoArray insertObject:self.MModel.picUrl atIndex:0];
            
            YYLog(@"当前绘本图片组:%@",self.photoArray);
            YYLog(@"%@",self.photoArray);
        }
    } fail:^(NSError *error) {
        
    } delegater:nil];
    
    
}

///JJJJJJJJJJJJJ****************************JJJJJJJJJJJJJJJJJJJJJJJJJJJJ


#pragma mark - 分享
-(void)shareAction{
    //
    NSMutableArray *titleArray = [NSMutableArray arrayWithObjects:@"微信",@"朋友圈",@"QQ",@"空间", nil];
    NSMutableArray *picArray = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    
    ShareView *share = [[ShareView alloc]initWithTitleArray:titleArray picArray:picArray];
    [share showShareView];
    [share currentIndexWasSelected:^(NSInteger index) {
        NSLog(@"%ld",(long)index);
    }];
}
@end
